package homework3;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoField;
import java.util.Arrays;
import java.util.List;

/**
 * @classname:NewWhatTime
 * @description:
 * @author: Mr.Z
 * @date: 2020/12/15 20:00
 * @version: 0.1
 * @since:1.8
 */
public class NewWhatTime {
    public static void main(String[] args) {
        String str = "2020-12-12 12-00-00";
        String weekName = getWeekName(str);
        System.out.println(weekName);
    }

    private static String getWeekName(String timeStr) {
        DateTimeFormatter dateTimeFormatter =  DateTimeFormatter.ofPattern("yyyy-MM-dd HH-mm-ss");
        LocalDateTime time = LocalDateTime.parse(timeStr, dateTimeFormatter);
        int i = time.get(ChronoField.DAY_OF_WEEK);
        List<String> list = Arrays.asList("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
        return list.get(i);
    }
}
